<template>
  <div>
    <h2>我是Home的内容</h2>

    <div class="nav">
      <router-link class="router" active-class="active" to="/home/message">message</router-link>
      <router-link class="router" active-class="active" to="/home/news">News</router-link>
    </div>
    <keep-alive include="message">
      <router-view></router-view>
    </keep-alive>
  </div>

</template>
<script>
export default {
  name: "Home",
  mounted() {
    console.log('home组件被使用', this)
  },
  beforeDestroy() {
    console.log('home组件被销毁')
  }
}
</script>

<style scoped>
.router {
  display: block;
  width: 100px;
  height: 30px;
  border: 1px solid black;
  line-height: 30px;
  text-align: center;
  color: black;
  outline: none;
  text-decoration: none;

}

.nav {
  display: flex;
}

.active {
  background-color: #4444ed;
  color: white;
}
</style>